package com.lxh.lxhcrm.model.pojos;

import javax.persistence.*;
import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * 客户表
 */
@Entity
@Table(name = "customer", schema = "lxh_crm", catalog = "")
public class Customer {
    private int customerId;
    private String customerName;
    private String pro;
    private String city;
    private String remarks;
    private Date creatDate;
    private Date allocateTime;
    private Date fallDate;
    private String emailAddress;
    /**
     * 客户阶段标识 线索1 沟通中2 机会客户3 合同客户4 成交客户5
     */
    private  CusStage cusStage;
    private Integer contractNum = 0;// 合同数 默认为0
    private String workAddress;
        private String customerLable;//客户标签（暂放，可能不会做）
    private Date nextVisitTime;
    private  Integer isFocus;//是否关注

    //多对一，客户类型
    private CustomerType cusType;
    //多对一， 公海
    private Sea sea;
    //多对一，客户来源
    private CustomerSource cusSource;
    //多对一，创建人
    private Emp creater;
    //多对一，拥有者
    private Emp owner;
    //一对多，联系人
    private List<Contact> contact;

    @OneToMany(mappedBy = "customer")
    public List<Contact> getContact() {
        return contact;
    }
    public void setContact(List<Contact> contact) {
        this.contact = contact;
    }

    @ManyToOne
    @JoinColumn(name = "customer_type_id")
    public CustomerType getCusType() {
        return cusType;
    }
    public void setCusType(CustomerType cusType) {
        this.cusType = cusType;
    }

    @ManyToOne
    @JoinColumn(name = "stage_id")
    public CusStage getCusStage() {
        return cusStage;
    }
    public void setCusStage(CusStage cusStage) {
        this.cusStage = cusStage;
    }

    @ManyToOne
    @JoinColumn(name = "sea_id")
    public Sea getSea() {
        return sea;
    }
    public void setSea(Sea sea) {
        this.sea = sea;
    }

    @ManyToOne
    @JoinColumn(name = "customer_source_id")
    public CustomerSource getCusSource() {
        return cusSource;
    }
    public void setCusSource(CustomerSource cusSource) {
        this.cusSource = cusSource;
    }

    @ManyToOne
    @JoinColumn(name = "creater_id")
    public Emp getCreater() {
        return creater;
    }
    public void setCreater(Emp creater) {
        this.creater = creater;
    }

    @ManyToOne
    @JoinColumn(name = "owner_id")
    public Emp getOwner() {
        return owner;
    }
    public void setOwner(Emp owner) {
        this.owner = owner;
    }

    @Id
    @Column(name = "customer_id", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public int getCustomerId() {
        return customerId;
    }
    public void setCustomerId(int customerId) {
        this.customerId = customerId;
    }


    @Basic
    @Column(name = "is_focus", nullable = true)
    public Integer getIsFocus() {
        return isFocus;
    }
    public void setIsFocus(Integer isFocus) {
        this.isFocus = isFocus;
    }

    @Basic
    @Column(name = "customer_name", nullable = true, length = 40)
    public String getCustomerName() {
        return customerName;
    }

    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }


    @Basic
    @Column(name = "pro", nullable = true)
    public String getPro() {
        return pro;
    }

    public void setPro(String pro) {
        this.pro = pro;
    }

    @Basic
    @Column(name = "city", nullable = true)
    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    @Basic
    @Column(name = "remarks", nullable = true, length = 200)
    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    @Basic
    @Column(name = "creat_date", nullable = true)
    public Date getCreatDate() {
        return creatDate;
    }

    public void setCreatDate(Date creatDate) {
        this.creatDate = creatDate;
    }


    @Basic
    @Column(name = "allocate_time", nullable = true)
    public Date getAllocateTime() {
        return allocateTime;
    }

    public void setAllocateTime(Date allocateTime) {
        this.allocateTime = allocateTime;
    }

    @Basic
    @Column(name = "fall_date", nullable = true)
    public Date getFallDate() {
        return fallDate;
    }

    public void setFallDate(Date fallDate) {
        this.fallDate = fallDate;
    }

    @Basic
    @Column(name = "email_address", nullable = true, length = 100)
    public String getEmailAddress() {
        return emailAddress;
    }

    public void setEmailAddress(String emailAddress) {
        this.emailAddress = emailAddress;
    }


    @Basic
    @Column(name = "contract_num", nullable = true)
    public Integer getContractNum() {
        return contractNum;
    }

    public void setContractNum(Integer contractNum) {
        this.contractNum = contractNum;
    }

    @Basic
    @Column(name = "work_address", nullable = true, length = 100)
    public String getWorkAddress() {
        return workAddress;
    }

    public void setWorkAddress(String workAddress) {
        this.workAddress = workAddress;
    }

    @Basic
    @Column(name = "customer_lable", nullable = true, length = 10)
    public String getCustomerLable() {
        return customerLable;
    }

    public void setCustomerLable(String customerLable) {
        this.customerLable = customerLable;
    }

    @Basic
    @Column(name = "next_visit_time", nullable = true)
    public Date getNextVisitTime() {
        return nextVisitTime;
    }

    public void setNextVisitTime(Date nextVisitTime) {
        this.nextVisitTime = nextVisitTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Customer customer = (Customer) o;
        return customerId == customer.customerId &&
                Objects.equals(isFocus, customer.isFocus) &&
                Objects.equals(customerName, customer.customerName) &&
                Objects.equals(pro, customer.pro) &&
                Objects.equals(city, customer.city) &&
                Objects.equals(remarks, customer.remarks) &&
                Objects.equals(creatDate, customer.creatDate) &&
                Objects.equals(allocateTime, customer.allocateTime) &&
                Objects.equals(fallDate, customer.fallDate) &&
                Objects.equals(emailAddress, customer.emailAddress) &&
                Objects.equals(cusStage, customer.cusStage) &&
                Objects.equals(workAddress, customer.workAddress) &&
                Objects.equals(customerLable, customer.customerLable) &&
                Objects.equals(nextVisitTime, customer.nextVisitTime) &&
                Objects.equals(cusType, customer.cusType) &&
                Objects.equals(sea, customer.sea) &&
                Objects.equals(cusSource, customer.cusSource) &&
                Objects.equals(creater, customer.creater) &&
                Objects.equals(owner, customer.owner) &&
                Objects.equals(contact, customer.contact);
    }

    @Override
    public int hashCode() {
        return Objects.hash(customerId, isFocus, customerName, pro, city, remarks, creatDate, allocateTime, fallDate, emailAddress, cusStage, workAddress, customerLable, nextVisitTime, cusType, sea, cusSource, creater, owner, contact);
    }

    @Override
    public String toString() {
        return "Customer{" +
                "customerId=" + customerId +
                ", customerName='" + customerName + '\'' +
                ", pro='" + pro + '\'' +
                ", city='" + city + '\'' +
                ", remarks='" + remarks + '\'' +
                ", creatDate=" + creatDate +
                ", allocateTime=" + allocateTime +
                ", fallDate=" + fallDate +
                ", emailAddress='" + emailAddress + '\'' +
                ", cusStage=" + cusStage +
                ", contractNum=" + contractNum +
                ", workAddress='" + workAddress + '\'' +
                ", customerLable='" + customerLable + '\'' +
                ", nextVisitTime=" + nextVisitTime +
                ", isFocus=" + isFocus +
                ", cusType=" + cusType +
                ", sea=" + sea +
                ", cusSource=" + cusSource +
                ", creater=" + creater +
                ", owner=" + owner +
                ", contact=" + contact +
                '}';
    }
}
